package com.xx.controller;

import com.xx.entity.User;
import org.apache.catalina.LifecycleState;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping("user")
public class UserController {
    //返回用户信息
    @GetMapping
    public User getUserInfo(){
        User user = new User("lisi","nan",18,"beijing");
        return user;
    }

    @GetMapping("/list")
    public List<User> getList(){
        List<User> userList = new ArrayList<>();
        User user = new User("lisi","nan",18,"beijing");
        userList.add(user);
        User user2 = new User("wangwu","nan",18,"beijing");
        userList.add(user2);
        User user3 = new User("qianqi","nan",18,null);
        userList.add(user3);
        User user4 = new User("zhaoliu","nan",18,null);
        userList.add(user4);
        return userList;
    }
}
